package org.example.work3.gateway.config;

import org.example.work3.gateway.property.ServerGrayProperty;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.loadbalancer.core.ReactorServiceInstanceLoadBalancer;
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
@Deprecated
public class MyLoadBalancerConfig {

    /**
     * 只在启动时加载，无法动态刷新,需放入拦截器每次获取！！！
     */
//    @Autowired
    private ServerGrayProperty serverGrayProperty;

//    @Bean
    public ReactorServiceInstanceLoadBalancer myLoadBalancer(
            ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider) {
        return new VersionLoadBalancerClient(serverGrayProperty, serviceInstanceListSupplierProvider);
    }
}
